//
//  WSMacro.h
//  CharonTVProject
//
//  Created by karong on 2023/6/7.
//

#ifndef WSMacro_h
#define WSMacro_h

typedef void(^charonTV_EmptyBlock)();
typedef void(^charonTV_AnyObjectBlock)(id obj);
typedef void(^charonTV_ArrayBlock)(NSArray * charonTV_array);
typedef void(^charonTV_DictionaryBlock)(NSDictionary * charonTV_dict);
typedef void(^charonTV_StringBlock)(NSString * charonTV_string);
typedef void(^charonTV_IntegerBlock)(NSInteger charonTV_integer);
typedef void(^charonTV_ArrayDictionaryBlock)(NSArray *charonTV_array, NSDictionary *charonTV_dict);
typedef void(^charonTV_BoolBlock)(BOOL rec);

#define WeakSelf __weak typeof(self) weakSelf = self;

// 屏幕
#define WSScreenWidth        [UIScreen mainScreen].bounds.size.width
#define WSScreenHeight       [UIScreen mainScreen].bounds.size.height
// 设备
#define WSIsiPhoneX       (int)((kScreenHeight/kScreenWidth)*100) == 216.f

#ifdef DEBUG_ON
#define WLog(string, ...) NSLog(@"\n🐹%@  第%d行  %s\n🐹%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, [NSString stringWithFormat:(string), ##__VA_ARGS__])
#else
#define WLog(string, ...)
#endif

// 字符串格式化
#define WSSF(format, ...) ([NSString stringWithFormat:(format), ##__VA_ARGS__])
// 字符串非空判断
#define WSIsNullOrEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || str.length <= 0)
// 字符串空保护
#define WSEmptyStr(str) WSIsNullOrEmpty(str) ? @"" : str
// 读取本地圖片
#define WSIMG(file) ([UIImage imageNamed:(file)])

///默認圖片
#define WSPlaceholderImage [UIImage imageNamed:@"icon_tx_h"]
///默认用户头像
#define WSUserPlaceholderImage [UIImage imageNamed:@"icon_tx_w"]
///默认短剧封面
#define WSVideoPlaceholderImage [UIImage imageNamed:@"img_video_placeholder"]

#define appUserCenter           [WSUserCenter defaultSession]
#define appConfig               [WSAppConfig defaultSession]
#define appUserDefaults         [NSUserDefaults standardUserDefaults]
#define APPLocalized(key)         NSLocalizedString(key, nil)

// 单例
#define SingletonH + (instancetype)shared;
#define SingletonM \
static id _instance; \
+ (instancetype)allocWithZone:(struct _NSZone *)zone \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [super allocWithZone:zone]; \
    }); \
    return _instance; \
} \
+ (instancetype)shared \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [[self alloc] init]; \
    }); \
    return _instance; \
} \
- (id)copyWithZone:(NSZone *)zone \
{ \
    return _instance; \
}

#define RankTextColor       @[@"F63C3A", @"EEB12C", @"3A93E7", @"868686"]
// 适配比例
#define ADAPTATIONRATIO     WSScreenWidth / 750.0f
#define GKColorRGBA(r, g, b, a) [UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:a]
#define GKColorRGB(r, g, b)     GKColorRGBA(r, g, b, 1.0)
#define GKColorGray(v)          GKColorRGB(v, v, v)
#endif /* WSMacro_h */
